#include "system.h"
#include "SysTick.h"
#include "led.h"
#include "beep.h"
#include "key.h"

int main()
{
	u8 key,i=0;
	
	HAL_Init();											// 初始化HAL库
	SystemClock_Init(RCC_PLL_MUL9);	// 设置时钟，72M
	SysTick_Init(72);
	LED_init();
	BEEP_Init();
	KEY_Init();
	
	while(1)
	{
		key = KEY_Scan(0); // 扫描按键
		switch(key)
		{
			case KEY_UP_PRESS: 	LED2=0; break; // 点亮DS1
			case KEY1_PRESS:		LED2=1; break; // 熄灭DS1
			case KEY2_PRESS:		BEEP=1; break; // 打开蜂鸣
			case KEY0_PRESS:		BEEP=0; break; // 关闭蜂鸣
		}
		i++;
		if(i%20 == 0)
		{
			LED1 = !LED2;		// 200ms做一次翻转
		}
		delay_ms(10);
	}
}

